package com.app.scale.bean;


import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Index;
import org.greenrobot.greendao.annotation.Generated;

import my.MathUtils;

@Entity(indexes = {@Index(value = "cna,cno", unique = true)})

public class SupplierListData extends BasisBean {


    /**
     *  {
     *       "cid": null,
     *       "aid": null,
     *       "cno": "10001",            //编号
     *       "cna": "测试10001",      //姓名
     *       "cdr": null,           //地址
     *       "ctel": null,      //电话
     *       "cmn": null,       //联系人
     *       "ict": null,       //初期金额
     *       "ins": null,       //初期票款
     *       "cht": null,       //证件号
     *       "uid": null,
     *       "cfsign": null,
     *       "prp": null,           //茶园性质
     *       "acr": null,        //亩数
     *       "cdno": null,       //卡号
     *       "cfs": null ，        //属性：代理商，茶农
     *        "files":"/company/showimage?filename=32110140003.jpg",
     *       "tra1": null         //银针溯源余量
     *       "tra2": null         //牡丹溯源余量
     *       "tra3": null         //寿眉溯源余量
     *     }
     */
    private static final long serialVersionUID = 1L;


    @JSONField(name = "cid")
    private String cid;
    @JSONField(name = "cno")
    private String cno;
    @JSONField(name = "cna")
    private String cna;
    @JSONField(name = "cdr")
    private String cdr;
    @JSONField(name = "ctel")
    private String ctel;
    @JSONField(name = "cmn")
    private String cmn;
    @JSONField(name = "ict")
    private String ict;
    @JSONField(name = "ins")
    private String ins;
    @JSONField(name = "cht")
    private String cht;
    @JSONField(name = "cfsign")
    private String cfsign;     //1是客户  2是供应商
    @JSONField(name = "prp")
    private String prp;
    @JSONField(name = "acr")
    private String acr;
    @JSONField(name = "cdno")
    private String cdno;
    @JSONField(name = "cfs")
    private String cfs;
    @JSONField(name = "files")
    private String files;
    @JSONField(name = "imgex")
    private String imgex;
    @JSONField(name = "tra1")
    private String tra1;
    @JSONField(name = "tra2")
    private String tra2;
    @JSONField(name = "tra3")
    private String tra3;

    @JSONField(name = "bno")
    private String bno;



    @JSONField(serialize = false)
    private String editTra1;
    @JSONField(serialize = false)
    private String editTra2;
    @JSONField(serialize = false)
    private String editTra3;



    @Generated(hash = 1365533022)
    public SupplierListData(String cid, String cno, String cna, String cdr,
            String ctel, String cmn, String ict, String ins, String cht,
            String cfsign, String prp, String acr, String cdno, String cfs,
            String files, String imgex, String tra1, String tra2, String tra3,
            String bno, String editTra1, String editTra2, String editTra3) {
        this.cid = cid;
        this.cno = cno;
        this.cna = cna;
        this.cdr = cdr;
        this.ctel = ctel;
        this.cmn = cmn;
        this.ict = ict;
        this.ins = ins;
        this.cht = cht;
        this.cfsign = cfsign;
        this.prp = prp;
        this.acr = acr;
        this.cdno = cdno;
        this.cfs = cfs;
        this.files = files;
        this.imgex = imgex;
        this.tra1 = tra1;
        this.tra2 = tra2;
        this.tra3 = tra3;
        this.bno = bno;
        this.editTra1 = editTra1;
        this.editTra2 = editTra2;
        this.editTra3 = editTra3;
    }

    @Generated(hash = 1995885253)
    public SupplierListData() {
    }



    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }

    public String getCno() {
        return cno;
    }

    public void setCno(String cno) {
        this.cno = cno;
    }

    public String getCna() {
        return cna;
    }

    public void setCna(String cna) {
        this.cna = cna;
    }

    public String getCdr() {
        return cdr;
    }

    public void setCdr(String cdr) {
        this.cdr = cdr;
    }

    public String getCtel() {
        return ctel;
    }

    public void setCtel(String ctel) {
        this.ctel = ctel;
    }

    public String getCmn() {
        return cmn;
    }

    public void setCmn(String cmn) {
        this.cmn = cmn;
    }

    public String getIct() {
        return ict;
    }

    public void setIct(String ict) {
        this.ict = ict;
    }

    public String getIns() {
        return ins;
    }

    public void setIns(String ins) {
        this.ins = ins;
    }

    public String getCht() {
        if(TextUtils.isEmpty(cht)){
            return "";
        }
        return cht;
    }

    public void setCht(String cht) {
        this.cht = cht;
    }

    public String getCfsign() {
        return cfsign;
    }

    public void setCfsign(String cfsign) {
        this.cfsign = cfsign;
    }

    public String getPrp() {
        return prp;
    }

    public void setPrp(String prp) {
        this.prp = prp;
    }

    public String getAcr() {
        return acr;
    }

    public void setAcr(String acr) {
        this.acr = acr;
    }

    public String getCdno() {
        return cdno;
    }

    public void setCdno(String cdno) {
        this.cdno = cdno;
    }

    public String getCfs() {
        return cfs;
    }

    public void setCfs(String cfs) {
        this.cfs = cfs;
    }

    public String getFiles() {
        return files;
    }

    public void setFiles(String files) {
        this.files = files;
    }

    public String getImgex() {
        return imgex;
    }

    public void setImgex(String imgex) {
        this.imgex = imgex;
    }

    public String getTra1() {
        if(TextUtils.isEmpty(tra1) || "null".equals(tra1)) return "0";
        return tra1;
    }

    public void setTra1(String tra1) {
        this.tra1 = tra1;
    }

    public String getTra2() {
        if(TextUtils.isEmpty(tra2) || "null".equals(tra2)) return "0";
        return tra2;
    }

    public void setTra2(String tra2) {
        this.tra2 = tra2;
    }

    public String getTra3() {
        if(TextUtils.isEmpty(tra3) || "null".equals(tra3)) return "0";
        return tra3;
    }

    public void setTra3(String tra3) {
        this.tra3 = tra3;
    }

    @JSONField(serialize = false)
    public String getEditTra1() {
        if(TextUtils.isEmpty(editTra1) || "null".equals(editTra1)) return "0";
        return editTra1;
    }
    @JSONField(serialize = false)
    public void setEditTra1(String editTra1) {
        this.editTra1 = editTra1;
    }
    @JSONField(serialize = false)
    public String getEditTra2() {
        if(TextUtils.isEmpty(editTra2) || "null".equals(editTra2)) return "0";
        return editTra2;
    }
    @JSONField(serialize = false)
    public void setEditTra2(String editTra2) {
        this.editTra2 = editTra2;
    }
    @JSONField(serialize = false)
    public String getEditTra3() {
        if(TextUtils.isEmpty(editTra3) || "null".equals(editTra3)) return "0";
        return editTra3;
    }
    @JSONField(serialize = false)
    public void setEditTra3(String editTra3) {
        this.editTra3 = editTra3;
    }

    @JSONField(serialize = false)
    public String editTra1AddTra1() {
      return MathUtils.add(getEditTra1(),getTra1());
    }

    @JSONField(serialize = false)
    public String editTra2AddTra2() {
        return MathUtils.add(getEditTra2(),getTra2());
    }

    @JSONField(serialize = false)
    public String editTra3AddTra3() {
        return MathUtils.add(getEditTra3(),getTra3());
    }

    public String getBno() {
        return bno;
    }

    public void setBno(String bno) {
        this.bno = bno;
    }

    public void setAutoBno(String value){
//        http://www.fdbcdsj.cn:8880/QRHome/Scan/79855
        String a = value.replace("http://www.fdbcdsj.cn:8880/QRHome/Scan/","");
        this.bno = a;
    }

    public String getAutoBno(){
        if(TextUtils.isEmpty(getBno()) || "null".equals(getBno())) return null;
       return "http://www.fdbcdsj.cn:8880/QRHome/Scan/"+getBno();
    }

}
